// Table 2:
do "$ados/FHBoundsCode.ado"
	// Estimate the FH Bounds
		use "$dir\DataSCLB", clear
			set seed 67296786
			fhbounds EL_EGRA_PCA_Index, r(1000) treatment(MT_Program CCT_Program) control(Control) strata(Group_blind) cluster(School_blind) bias

			keep if p==5 | p==25 | p==50 | p==75 | p==95  | (p>99)
			keep p_exp *_st i p sortvar
			
			save "$output/Table2.dta", replace
			
			gen blank = ""
			
			keep p i *lo* 
			keep if p<100
			egen group = group(p)
			gsort - group i
			gen sortvar = _n
			rename FH_lo_MT_Program_pt_st  FH_lo_MT_Program_pt_st_rev
			rename FH_lo_CCT_Program_pt_st FH_lo_CCT_Program_pt_st_rev
			tempfile reverse
			save `reverse'
			use "$output/Table2.dta", clear
			drop sortvar
			gen sortvar = _n
			qui merge 1:1 sortvar using `reverse', keepusing(*_rev)
			qui replace FH_lo_MT_Program_pt_st = FH_lo_MT_Program_pt_st_rev if _merge==3
			qui replace FH_lo_CCT_Program_pt_st = FH_lo_CCT_Program_pt_st_rev if _merge==3
			
			replace p = 100 if p==102
			replace p = 100.5 if p==103
			sort p i
			drop _merge FH_lo_MT_Program_pt_st_rev FH_lo_CCT_Program_pt_st_rev sortvar i p
			
			
# delimit ;			
texsave p_exp FH_up_MT_Program_pt_st FH_lo_MT_Program_pt_st blank FH_up_CCT_Program_pt_st FH_lo_CCT_Program_pt_st using "$output/T2.tex", 
					replace align(rccccc) location(H) width(\textwidth) hlines(10)
					headerlines("& \multicolumn{2}{c}{Full-cost Program} & & \multicolumn{2}{c}{Reduced-cost Program} \\ 
					\cmidrule{2-3} \cmidrule{5-6} & Rank & Rank & & Rank & Rank \\ 
					& Preservation & Inversion & & Preservation   & Inversion \\
					& (1) & (2) & & (3) & (4) ") 
					marker(tb:fhbounds) title(\\ Fréchet-Höffding Bounds) 
					size(small) frag nonames nofix ;
# delimit cr					